package com.imast.android.bys.adapter;

import java.util.List;

import com.imast.android.bys.io.model.Categoria;
import com.imast.android.bys.ui.fragment.ProductoFragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

public class CategoriaPageAdapter extends FragmentStatePagerAdapter {
	
	private List<Categoria> lstCategoria;
	
	public CategoriaPageAdapter(FragmentManager fm, List<Categoria> lstCategoria) {
		super(fm);
		
		this.lstCategoria = lstCategoria;
	}

	@Override
	public Fragment getItem(int position) {
		Fragment fragment = new ProductoFragment();
		Bundle args = new Bundle();
		args.putInt(ProductoFragment.ARG_TITLE, lstCategoria.get(position).getIdCategoria());
		args.putInt(ProductoFragment.ARG_INDEX, position);
		fragment.setArguments(args);
        return fragment;
	}

	@Override
	public int getCount() {
		return lstCategoria.size();
	}
	
	@Override
    public CharSequence getPageTitle(int position) {
        return lstCategoria.get(position).getTitulo();
    }

}
